<template>
    <div>
        <div class="mui-numbox" data-numbox-min="1">
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input ref="num" @change="countChange" readonly class="mui-input-numbox" type="number" :value="initCount">
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
        </div>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'
    export default {
        name: "shopcar_number",
        props:['initCount','goodsId'],
        mounted(){
            //初始化数字框的控件
            mui('.mui-numbox').numbox();
        },
        methods:{
            countChange(){
                // console.log(this.$refs.num)
                this.$store.commit('updateCount',{id:this.goodsId,count:this.$refs.num.value})
            }
        }
    }
</script>

<style scoped>
    .mui-numbox{
        margin: 0 10px;
    }
</style>